import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
  {
    path: '/login',
    name: 'Login',
    component: () => import('../pages/login.vue')
  },
  {
    path: '/index',
    name: 'Index',
    component: () => import(/* webpackChunkName: "index" */ '../pages/index.vue'),
    children: [
      {
        path: '/home',
        component: () => import('../views/Home.vue')
      },
      {
        path: '/menu',
        component: () => import('../views/Menu.vue')
      },
      {
        path: '/user',
        component: () => import('../views/Users.vue')
      },
      {
        path: '/admin',
        component: () => import('../views/Admin.vue')
      },
      {
        path: '/category',
        component: () => import('../views/ProductCategory.vue')
      },
      {
        path: '/specs',
        component: () => import('../views/ProductSpecs.vue')
      },
      {
        path: '/manage',
        component: () => import('../views/ProductManage.vue')
      },
      {
        path: '/member',
        component: () => import('../views/Member.vue')
      },
      {
        path: '/banner',
        component: () => import('../views/Banner.vue')
      },
      {
        path: '/seckill',
        component: () => import('../views/Seckill.vue')
      },
      {
        path: '',
        redirect: '/home'
      }
    ]
  },
  {
    path: '*',
    redirect: '/index'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
